'use strict';
import React, {Component} from 'react';
import {
    Alert,
    Platform,
} from 'react-native';
import * as types from '../constants/action-types';

import Http from '../core/utils/http';
import API from '../constants/server-apis';
import InitDB from '../core/database/init-db';
import Util from '../core/utils/util';

//搜索
export function search(cfg) {
    return dispatch => {
        const params = Object.assign({
            keyword:'',
            objId:'searchService',
            pageSize:'10',
            pageNo:'1',
        },cfg);
        return Http.fetch(API.API_SEARCH_SERVICE_URL, params).then(json=>{
            if(json && json.hasOwnProperty('searchService')){
                dispatch(receiveSearch(json.searchService))
            }
            return json;
        })
    }
}

function fetchSearch() {
    return {
        type: types.FETCH_COMMON_SEARCH_RESULT,
    };
}

function receiveSearch(searchService) {
    return {
        type: types.FETCH_DONG_TAIN_NEAR_RESULT,
        searchService: searchService,
    };
}
